package com.it00zyq.admin.controller;

import com.it00zyq.admin.param.ScheduleParam;
import com.it00zyq.admin.service.ScheduleService;
import com.it00zyq.admin.service.TypeService;
import com.it00zyq.common.param.ListParam;
import com.it00zyq.common.utils.R;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @Author zyq
 * @Date 2022/4/29 16:41
 * @Description TODO
 * @Version 1.0
 **/
@RestController
@RequestMapping("/api/schedule")
@RequiredArgsConstructor
public class ScheduleController {

    private final ScheduleService service;

    /**
     * 日程列表分页查询
     */
    @GetMapping
    public R list(ListParam param, @RequestHeader("token") String token) {
        return R.ok().data(service.list(param, token));
    }

    /**
     * 添加日程
     */
    @PostMapping
    public R add(@RequestBody @Valid ScheduleParam param, @RequestHeader("token") String token) {
        service.add(param, token);
        return R.ok();
    }

    /**
     * 修改日程
     */
    @PutMapping
    public R modify(@RequestBody @Valid ScheduleParam param) {
        service.modify(param);
        return R.ok();
    }

    /**
     * 删除日程
     */
    @DeleteMapping("/{id}")
    public R delete(@PathVariable("id") Integer id) {
        service.delete(id);
        return R.ok();
    }


}
